package com.example.jupiter.test;

import android.R;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.TextView;

import com.gorillalogic.monkeytalk.demo1.LoginActivity;
import com.gorillalogic.monkeytalk.demo1.LogoutActivity;
import com.robotium.solo.Solo;

public class test_login extends ActivityInstrumentationTestCase2<LoginActivity> {

	Solo solo;

	public test_login() {
		super(LoginActivity.class);
	}

	protected void setUp() throws Exception {
		solo = new Solo(getInstrumentation(), getActivity());
	}

	protected void tearDown() throws Exception {
		solo.finishOpenedActivities();
	}

	public void testPreferenceIsSaved() throws Exception {

		
		solo.clickOnView(solo.getView("login_usr"));
		solo.enterText(0, "hello");
		solo.clickOnView(solo.getView("login_pwd"));
		solo.enterText(1, "pass2223");
		String txt=((TextView)solo.getView("login_usr")).getText().toString();
		solo.clickOnButton("LOGIN");
		solo.sleep(4000);
		assertEquals("Welcome, "+txt+"!",((TextView)solo.getView("logout_txt")).getText().toString());
		
		//solo.assertCurrentActivity("True", LogoutActivity.class);
		solo.clickOnButton("LOGOUT");
 
	}

}
